import type { PageResult, ResponseBody } from "@/api/typing";
import { request } from "@/utils/request";
import type {
  DeleteParams,
  PublishParams,
  QueryParams,
  QueryResult,
  ViewParams,
} from "./typing";

/**新增视图 */
export const add = (params: ViewParams) => {
  return request.post<ViewParams, ResponseBody>("/low-code/view/add", params);
};

/**修改视图 */
export const update = (params: ViewParams) => {
  return request.put<ViewParams, ResponseBody>("/low-code/view/update", params);
};

/**分页查询视图 */
export const queryByPage = (params: QueryParams) => {
  return request.get<QueryParams, ResponseBody<PageResult<QueryResult>>>(
    "/low-code/view/page",
    { params }
  );
};

/**删除视图 */
export const del = (params: DeleteParams) => {
  return request.delete<DeleteParams, ResponseBody>("/low-code/view/delete", {
    params,
  });
};

/**发布视图 */
export const publish = (params: PublishParams) => {
  return request.put<PublishParams, ResponseBody>(
    "/low-code/view/publish",
    params
  );
};
